package t20211226;

/**
 * @Author: DengJia
 * @Date: 2021/12/26 16:40
 * @Description:
 */
public class InheritingException {
    public void f() throws SimpleException {
        System.out.println("throw SimpleException from f()~");
        throw new SimpleException();
    }

    public void g() throws SimpleException {
        System.out.println("throw SimpleException from g()~");
        throw new SimpleException("异常报错描述信息");
    }
}

class SimpleException extends Exception {
    public SimpleException() {
    }

    public SimpleException(String message) {
        super(message);
    }

    public static void main(String[] args) {
        InheritingException ie = new InheritingException();
        try {
            ie.f();
        } catch (SimpleException e) {
            // 打印堆栈跟踪信息
            e.printStackTrace(System.out);
        }

        try {
            ie.g();
        } catch (SimpleException e) {
            e.printStackTrace(System.err);
        }
    }
}
